package com.quickask.entity;

import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;

/**
 * Created by NaSa on 2015/9/23.
 */
@Entity
@Table(name = "asknow_question_set", schema = "", catalog = "quickask")
@org.hibernate.annotations.Cache(usage= CacheConcurrencyStrategy.READ_WRITE, region = "com.quickask.entity.AsknowQuestionSetEntity")
public class AsknowQuestionSetEntity implements Serializable {
    private int questionId;  //问题id
    private Timestamp questionAsktime;  //提问时间
    private Integer questionAsknum;  //同问数
    private Integer questionAnswernum; //回答数
    private String questionContent;  //问题文字描述内容
    private String questionDescription;  //问题描述(副标题)
    private Integer userId;  //提问者id
    private Integer answerId; //被推荐为最佳的答案
    private Integer questionPoint;  //问题积分点
    private Byte questionIsSolved;  //问题是否已解决，0未解决，1已解决，默认0
    private Byte questionIsAlived;  //问题是否仍然有效,0无效，1有效，默认1
    private String questionImageUrls;  //问题图片链接地址
    private String questionVoiceUrls;  //语音问题链接地址

    private AsknowQuestionLocationSetEntity asknowQuestionLocationSetEntity;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "questionId", nullable = false, insertable = true, updatable = true)
    public int getQuestionId() {
        return questionId;
    }

    public void setQuestionId(int questionId) {
        this.questionId = questionId;
    }

    @Column(name = "questionAsktime", nullable = true, insertable = true, updatable = true)
    public Timestamp getQuestionAsktime() {
        return questionAsktime;
    }

    public void setQuestionAsktime(Timestamp questionAsktime) {
        this.questionAsktime = questionAsktime;
    }

    @Column(name = "questionAsknum", nullable = true, insertable = true, updatable = true)
    public Integer getQuestionAsknum() {
        return questionAsknum;
    }

    public void setQuestionAsknum(Integer questionAsknum) {
        this.questionAsknum = questionAsknum;
    }

    @Column(name = "questionAnswernum", nullable = true, insertable = true, updatable = true)
    public Integer getQuestionAnswernum() {
        return questionAnswernum;
    }

    public void setQuestionAnswernum(Integer questionAnswernum) {
        this.questionAnswernum = questionAnswernum;
    }

    @Column(name = "questionContent", nullable = true, insertable = true, updatable = true, length = 65535)
    public String getQuestionContent() {
        return questionContent;
    }

    public void setQuestionContent(String questionContent) {
        this.questionContent = questionContent;
    }

    @Column(name = "questionDescription", nullable = true, insertable = true, updatable = true, length = 200)
    public String getQuestionDescription() {
        return questionDescription;
    }

    public void setQuestionDescription(String questionDescription) {
        this.questionDescription = questionDescription;
    }

    @Column(name = "userId", nullable = true, insertable = true, updatable = true)
    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    @Column(name = "answerId", nullable = true, insertable = true, updatable = true)
    public Integer getAnswerId() {
        return answerId;
    }

    public void setAnswerId(Integer answerId) {
        this.answerId = answerId;
    }

    @Column(name = "questionPoint", nullable = true, insertable = true, updatable = true)
    public Integer getQuestionPoint() {
        return questionPoint;
    }

    public void setQuestionPoint(Integer questionPoint) {
        this.questionPoint = questionPoint;
    }

    @Column(name = "questionIsSolved", nullable = true, insertable = true, updatable = true, scale = 1)
    public Byte getQuestionIsSolved() {
        return questionIsSolved;
    }

    public void setQuestionIsSolved(Byte questionIsSolved) {
        this.questionIsSolved = questionIsSolved;
    }

    @Column(name = "questionIsAlived", nullable = true, insertable = true, updatable = true, scale = 1)
    public Byte getQuestionIsAlived() {
        return questionIsAlived;
    }

    public void setQuestionIsAlived(Byte questionIsAlived) {
        this.questionIsAlived = questionIsAlived;
    }

    @Column(name = "questionImageUrls", nullable = true, insertable = true, updatable = true, length = 10000)
    public String getQuestionImageUrls() {
        return questionImageUrls;
    }

    public void setQuestionImageUrls(String questionImageUrls) {
        this.questionImageUrls = questionImageUrls;
    }

    @Column(name = "questionVoiceUrls", nullable = true, insertable = true, updatable = true, length = 10000)
    public String getQuestionVoiceUrls() {
        return questionVoiceUrls;
    }

    public void setQuestionVoiceUrls(String questionVoiceUrls) {
        this.questionVoiceUrls = questionVoiceUrls;
    }

    @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
    @JoinColumn(name = "questionId")
    public AsknowQuestionLocationSetEntity getAsknowQuestionLocationSetEntity() {
        return asknowQuestionLocationSetEntity;
    }

    public void setAsknowQuestionLocationSetEntity(AsknowQuestionLocationSetEntity asknowQuestionLocationSetEntity) {
        this.asknowQuestionLocationSetEntity = asknowQuestionLocationSetEntity;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof AsknowQuestionSetEntity)) return false;

        AsknowQuestionSetEntity that = (AsknowQuestionSetEntity) o;

        if (questionId != that.questionId) return false;
        if (questionAsktime != null ? !questionAsktime.equals(that.questionAsktime) : that.questionAsktime != null)
            return false;
        if (questionAsknum != null ? !questionAsknum.equals(that.questionAsknum) : that.questionAsknum != null)
            return false;
        if (questionAnswernum != null ? !questionAnswernum.equals(that.questionAnswernum) : that.questionAnswernum != null)
            return false;
        if (questionContent != null ? !questionContent.equals(that.questionContent) : that.questionContent != null)
            return false;
        if (questionDescription != null ? !questionDescription.equals(that.questionDescription) : that.questionDescription != null)
            return false;
        if (userId != null ? !userId.equals(that.userId) : that.userId != null) return false;
        if (answerId != null ? !answerId.equals(that.answerId) : that.answerId != null) return false;
        if (questionPoint != null ? !questionPoint.equals(that.questionPoint) : that.questionPoint != null)
            return false;
        if (questionIsSolved != null ? !questionIsSolved.equals(that.questionIsSolved) : that.questionIsSolved != null)
            return false;
        if (questionIsAlived != null ? !questionIsAlived.equals(that.questionIsAlived) : that.questionIsAlived != null)
            return false;
        if (questionImageUrls != null ? !questionImageUrls.equals(that.questionImageUrls) : that.questionImageUrls != null)
            return false;
        if (questionVoiceUrls != null ? !questionVoiceUrls.equals(that.questionVoiceUrls) : that.questionVoiceUrls != null)
            return false;
        return !(asknowQuestionLocationSetEntity != null ? !asknowQuestionLocationSetEntity.equals(that.asknowQuestionLocationSetEntity) : that.asknowQuestionLocationSetEntity != null);

    }

    @Override
    public int hashCode() {
        int result = questionId;
        result = 31 * result + (questionAsktime != null ? questionAsktime.hashCode() : 0);
        result = 31 * result + (questionAsknum != null ? questionAsknum.hashCode() : 0);
        result = 31 * result + (questionAnswernum != null ? questionAnswernum.hashCode() : 0);
        result = 31 * result + (questionContent != null ? questionContent.hashCode() : 0);
        result = 31 * result + (questionDescription != null ? questionDescription.hashCode() : 0);
        result = 31 * result + (userId != null ? userId.hashCode() : 0);
        result = 31 * result + (answerId != null ? answerId.hashCode() : 0);
        result = 31 * result + (questionPoint != null ? questionPoint.hashCode() : 0);
        result = 31 * result + (questionIsSolved != null ? questionIsSolved.hashCode() : 0);
        result = 31 * result + (questionIsAlived != null ? questionIsAlived.hashCode() : 0);
        result = 31 * result + (questionImageUrls != null ? questionImageUrls.hashCode() : 0);
        result = 31 * result + (questionVoiceUrls != null ? questionVoiceUrls.hashCode() : 0);
        result = 31 * result + (asknowQuestionLocationSetEntity != null ? asknowQuestionLocationSetEntity.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "AsknowQuestionSetEntity{" +
                "questionId=" + questionId +
                ", questionAsktime=" + questionAsktime +
                ", questionAsknum=" + questionAsknum +
                ", questionAnswernum=" + questionAnswernum +
                ", questionContent='" + questionContent + '\'' +
                ", questionDescription='" + questionDescription + '\'' +
                ", userId=" + userId +
                ", answerId=" + answerId +
                ", questionPoint=" + questionPoint +
                ", questionIsSolved=" + questionIsSolved +
                ", questionIsAlived=" + questionIsAlived +
                ", questionImageUrls='" + questionImageUrls + '\'' +
                ", questionVoiceUrls='" + questionVoiceUrls + '\'' +
                ", asknowQuestionLocationSetEntity=" + asknowQuestionLocationSetEntity +
                '}';
    }
}
